﻿using System;

namespace OperaterOvlApplication
{
    class Box
    {
        private double length; // 长度
        private double breadth; // 宽度
        private double height; // 高度

        public double GetVolume()
        {
            return length * breadth * height;
        }

        public void SetLength(double len)
        {
            length = len;
        }

        public void SetBreadth(double bre)
        {
            breadth = bre;
        }

        public void SetHeight(double hei)
        {
            height = hei;
        }

        // 重载 + 运算符来把两个 Box 对象相加
        public static Box operator +(Box b, Box c)
        {
            Box box = new Box();
            box.length = b.length + c.length;
            box.breadth = b.breadth + c.breadth;
            box.height = b.height + c.height;
            return box;
        }
    }
    class Tester
    {
        static void Main(string[] args)
        {
            Box box1 = new Box(); // 声明 box1，类型为 Box
            Box box2 = new Box(); // 声明 box2，类型为 Box
            Box box3 = new Box(); // 声明 box3，类型为 Box
            double volume = 0.0;

            // box1 详述
            box1.SetLength(6.0);
            box1.SetBreadth(7.0);
            box1.SetHeight(5.0);

            // box2 详述
            box2.SetLength(12.0);
            box2.SetBreadth(13.0);
            box2.SetHeight(10.0);

            // box1 的体积
            volume = box1.GetVolume();
            Console.WriteLine("Box1 的体积：{0}", volume);

            // box2 的体积
            volume = box2.GetVolume();
            Console.WriteLine("box2 的体积：{0}", volume);

            // 把两个对象相加
            box3 = box1 + box2;

            // box3 的体积
            volume = box3.GetVolume();
            Console.WriteLine("box3 的体积：{0}", volume);
            Console.ReadKey();
        }
    }
}